package com.hg.concurent.demo8;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author: skh
 * @Date: 2019/12/25 14:23
 * @Description:
 */
public class Singleton01 {

    private static Singleton01 instance = null;

    private Singleton01() {
        System.out.println(Thread.currentThread().getName() + "执行构造方法");
    }

    public static Singleton01 getInstance() {
        if (instance == null) {
            instance = new Singleton01();
        }
        return instance;
    }

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        for (int i = 0; i < 10; i++) {
            executorService.execute(() -> {
                Singleton01.getInstance();
            });
        }

        executorService.shutdown();
    }
}
